import { Util, Verify } from '@/ibiz-core/utils';
import { EntityLogicBase } from '@/ibiz-core';


/**
 * 实际费用与总计一致处理逻辑基类
 *
 * @export
 * @class ACTUAL_AMOUNTLogicBase
 * @extends {EntityLogicBase}
 */
export class ACTUAL_AMOUNTLogicBase extends EntityLogicBase {

    /**
     * 名称
     * 
     * @protected
     * @memberof ACTUAL_AMOUNTLogicBase
     */
    protected name:string ="ACTUAL_AMOUNT";

    /**
     * 唯一标识
     * 
     * @protected
     * @memberof ACTUAL_AMOUNTLogicBase
     */
    protected id:string = "86276c0968db53909914cc3d0724a2df";

    /**
     * 默认参数名称
     * 
     * @protected
     * @memberof ACTUAL_AMOUNTLogicBase
     */
    protected defaultParamName:string = "Default";

    /**
     * 执行逻辑
     * 
     * @param context 应用上下文
     * @param params 传入参数
     * @returns {Promise<any>}
     * @memberof ACTUAL_AMOUNTLogicBase
     */
    public onExecute(context: any, params: any): Promise<any> {
        return this.executeBegin(context, params);
    }


    /**
     * 开始
     * 
     * @protected
     * @param params 传入参数
     * @returns {Promise<any>}
     * @memberof ACTUAL_AMOUNTLogicBase
     */
    protected async executeBegin(context: any, params: any): Promise<any> {
        //开始节点
        return this.executePREPAREPARAM1(context, params);
    }

    /**
     * 准备参数
     * 
     * @protected
     * @param context 应用上下文
     * @param params 传入参数
     * @returns {Promise<any>}
     * @memberof ACTUAL_AMOUNTLogicBase
     */
    protected async executePREPAREPARAM1(context: any, params: any): Promise<any> {
        // 准备参数节点
        Object.assign(params, { actual_amount: params.total_amount });
        return this.executeEND1(context, params);
    }

    /**
     * 结束
     * 
     * @protected
     * @param context 应用上下文
     * @param params 传入参数
     * @returns {Promise<any>}
     * @memberof ACTUAL_AMOUNTLogicBase
     */
    protected async executeEND1(context: any, params: any): Promise<any> {
        throw new Error('END暂未支持');
    }

}